#include<vector>
using namespace std;

class Solution {
public:
    vector<int> findClosedNumbers(int num) {
        if (num == INT32_MAX) return { -1,-1 };
        vector<int>res = { -1,-1 };
        int cnt = 0;
        int rightOne = -1;
        int rightZero = -1;
        for (int i = 0; i < 32; ++i) {
            if ((num & (1 << i)) != 0) {
                if (rightOne == -1) rightOne = i;
                if (rightZero != -1 && res[1] == -1) {
                    res[1] = (num | (1 << rightZero)) & ~(1 << i);
                    ++cnt;
                }
            }
            else {
                if (rightOne != -1 && res[0] == -1) {
                    res[0] = (num | (1 << i)) & ~(1 << rightOne);
                    ++cnt;
                }
                rightZero = i;
            }
            if (cnt >= 2)  break;
        }
        return res;
    }
};

int main() {
    Solution sol;
    sol.findClosedNumbers(2);
}